<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="<?php echo site_url("style.css"); ?>" type="text/css" />
<title>Add Review/News</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
	<!-- header starts here -->
<div id="header">
  <div id="header-content"> 
    <ul>
      <li><a href="<?php echo site_url("admin/logout/"); ?>">Logout</a></li>
    </ul>
  </div>
</div>

<div id="content-wrap">
	
	<div id="nav">
		<img src="<?php echo site_url("images/Nav_Head.png"); ?>" alt="navigation header" class="no-border" />
		<a href="<?php echo site_url("review"); ?>"><img src="<?php echo site_url("images/Home_On.png"); ?>" alt="home" class="no-border" /></a>
		<a href="<?php echo site_url("review/reviews/default/0/A"); ?>"><img src="<?php echo site_url("images/Reviews_Off.png"); ?>" alt="reviews" class="no-border" /></a>
		<br />
		<div class="navlink"><a href="<?php echo site_url("admin/post/"); ?>">Add Post</a></div><br />
		<div class="navlink"><a href="<?php echo site_url("admin/add_series/"); ?>">Add Series</a></div><br />
		<div class="navlink"><a href="<?php echo site_url("admin/edit/post/0"); ?>">Edit Post/Review</a></div><br />
		<div class="navlink"><a href="<?php echo site_url("admin/edit/series/0"); ?>">Edit Series</a></div><br />
        <div class="navlink"><a href="<?php echo site_url("admin/manage_list/0"); ?>">Media Management</a></div><br />
		<div class="navlink"><a href="<?php echo site_url("admin/edit_schedule/"); ?>">Edit Schedule</a></div><br />
	</div>
		
<div id="adminwrapper">

<script language="JavaScript" type="text/JavaScript">
	var imageblocks = 0;
	
	function insertAtCaret(areaId,text) { 
	var txtarea = document.getElementById(areaId); 
	var scrollPos = txtarea.scrollTop; 
	var strPos = 0; 
	var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); 
		if (br == "ie") { txtarea.focus(); 
			var range = document.selection.createRange(); 
			range.moveStart ('character', -txtarea.value.length); 
			strPos = range.text.length; 
		} else if (br == "ff") strPos = txtarea.selectionStart; 
				var front = (txtarea.value).substring(0,strPos); 
				var back = (txtarea.value).substring(strPos,txtarea.value.length); 
				txtarea.value=front+text+back; 
				strPos = strPos + text.length; 
				if (br == "ie") { txtarea.focus(); 
					var range = document.selection.createRange(); 
					range.moveStart ('character', -txtarea.value.length); 
					range.moveStart ('character', strPos); 
					range.moveEnd ('character', 0); 
					range.select(); 
				} else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); 
					} 
			txtarea.scrollTop = scrollPos; 
	}
	
	function imgblk(areaId) {
	var text = '##' + imageblocks + '#';
	var txtarea = document.getElementById(areaId); 
	var scrollPos = txtarea.scrollTop; 
	var strPos = 0; 
	var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); 
		if (br == "ie") { txtarea.focus(); 
			var range = document.selection.createRange(); 
			range.moveStart ('character', -txtarea.value.length); 
			strPos = range.text.length; 
		} else if (br == "ff") strPos = txtarea.selectionStart; 
				var front = (txtarea.value).substring(0,strPos); 
				var back = (txtarea.value).substring(strPos,txtarea.value.length); 
				txtarea.value=front+text+back; 
				strPos = strPos + text.length; 
				if (br == "ie") { txtarea.focus(); 
					var range = document.selection.createRange(); 
					range.moveStart ('character', -txtarea.value.length); 
					range.moveStart ('character', strPos); 
					range.moveEnd ('character', 0); 
					range.select(); 
				} else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); 
					} 
			txtarea.scrollTop = scrollPos;
	imageblocks = imageblocks + 1;
	}

		
	function getimageurl() {
	var theurl = prompt("enter Image URL");
	if (theurl!=null && theurl!="")
		{
		var imgtag = '<img src=\"' + theurl + '\" alt=\"there used to be an image here\" />';
		insertAtCaret('messageBody',imgtag);
		}
	}
	
	function makealink() {
	var linkurl = prompt("enter full link URL");
	if (linkurl!=null && linkurl!="")
		{
		var linkname = prompt("display link as(leave blank to show URL):");
			if (linkname!=null && linkname!="")
				{
				var linktag = '<a href=\"' + linkurl + '\">' + linkname + '</a>';
				insertAtCaret('messageBody',linktag);
				}
			else
				{
				var linktag = '<a href=\"' + linkurl + '\">' + linkurl + '</a>';
				insertAtCaret('messageBody',linktag);
			}
	}
	}
	
	function center(areaId) {
	var txtarea = document.getElementById(areaId);
	var sel = (txtarea.value).substring(txtarea.selectionStart,txtarea.selectionEnd);
		if (sel!="")
			{
			var strPos = txtarea.selectionStart;
			var endPos = txtarea.selectionEnd; 
			var front = (txtarea.value).substring(0,strPos); 
			var back = (txtarea.value).substring(txtarea.selectionEnd,txtarea.value.length); 
			txtarea.value= front + '<span class=\"center\">' + sel + '</span>' + back;
			strPos = endPos + 28;
			txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus();
			}
		else
			{
			window.alert('You can center text that has already been entered by hilighting it first');
			var cen = '<span class=\"center\"></span>';
			insertAtCaret('messageBody',cen);
			var endPos = txtarea.selectionEnd;
			var strPos = endPos - 7;
			txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus();
			}
	}
		
</script>

<form action="<?php echo current_url(); ?>" method="post">
<fieldset><legend>Post</legend>

<br /><br />

<p><b>Topic:</b>&nbsp;<select name="topic">
            <option value="Review" selected="selected">Review</option>
            <option value="News">News</option>
            <option value="Misc">Misc</option>
        </select></p>
        
<p><i>**Series Title and Ep are only required when posting a review, leave them blank otherwise. If writing just a series overview 
or preview leave the preview box checked, otherwise uncheck it and enter the episode number being reviewed. TITLE is the heading of 
the article, and IS USED in conjunction with series title when writing a review.</i></p>

<p><i>Series Title:</i>&nbsp;<select name="series">
<?php

	$end = end($titles);
	foreach($titles as $row){
		if($row == $end){
			echo "<option value=\"$row->s_id\" selected=\"selected\">$row->name</option>";
		} else {
			echo "<option value=\"$row->s_id\">$row->name</option>";
		}
	}
?>
</select></p>

<p><i>Preview:</i><input type="checkbox" name="preview" value="1" checked="yes" />&nbsp;&nbsp;
    <i>Episode:</i>&nbsp;<input type="text" name="ep" size="3" maxlength="4" />&nbsp;&nbsp;
    <i>Final Review:</i><input type="checkbox" name="final" value="99"/></p>

<p><b>Title:</b>&nbsp;<input type="text" name="title" size="50" maxlength="256" /></p><br /><br />

<p><b>Post:</b><br />
<input type="button" value="Insert Automatic Image Block" onclick="imgblk('messageBody');" />&nbsp;&nbsp;
<input type="button" value="Insert Image" onclick="getimageurl();" />&nbsp;&nbsp;
<input type="button" value="Insert Link" onclick="makealink();" />&nbsp;&nbsp;
<input type="button" value="Center Tag" onclick="center('messageBody');" /><br />

<textarea name="content" id="messageBody" rows="20" cols="75"></textarea></p><br /><br />

<div align="center"><input type="submit" name="submit" value="Submit Post" /></div><br /><br />

</form><!-- End of Form -->		

		
	</div>
</div>

</body>
</html>

